﻿
@{
    ViewBag.Title = "发货单详情";
    Layout = "~/Views/Shared/_LayoutPage.cshtml";
}
@model IOA.MES.DataAccess.VModel.VDeliveryOrder

<div id="page"></div>

<script type="text/template" id="tplPage">
    <div style="padding: 20px; background-color: #F2F2F2;">
        <div class="layui-card">
            <div class="layui-card-body layui-form-item">
                <div class="layui-row">
                    <div class="layui-inline">
                        <label class="layui-form-label" v-html="lang.Field.DeliveryNo">发货单号：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="DeliveryNo" class="layui-input" value="@(Model?.DeliveryNo)" readonly />
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label" v-html="lang.Field.ContractNo">合同编号：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="ContractNo" class="layui-input" value="@(Model?.ContractNo)" readonly />
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label" v-html="lang.Field.DeliveryWarehouse">发货仓库：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="DeliveryNo" class="layui-input" value="@(Model?.WarehouseName)" readonly />
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label" v-html="lang.Field.DeliveryDate">发货日期：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="DeliveryDate" class="layui-input" value="@(Model?.DeliveryDate?.ToString("yyyy-MM-dd HH:mm:ss"))" readonly />
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label" v-html="lang.Field.CustomerInfo">客户信息：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="CustomerName" class="layui-input" value="@(Model?.CustomerName)" readonly />
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label" v-html="lang.Field.Quantity">数量：</label>
                        <div class="layui-input-inline">
                            <input type="number" name="Count" class="layui-input" value="@(Model?.Count)" readonly />
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-card">
            <div class="layui-card-header">
                发货清单
                @if (Model.Status == IOA.MES.DataAccess.Enum.DeliveryStatus.New)
                {
                    <button class="layui-btn layui-btn-sm" id="btnEdit" style="float:right; margin:5px;">导入柜号</button>
                }
            </div>
            <div class="layui-card-body">
                <table id="table" lay-filter="table"></table>
            </div>
        </div>
    </div>
</script>

@section Scripts{
    <script>
        var vm = new Vue({
            el: "#page",
            template: "#tplPage",
            data: {
                lang: JSON.parse(lang).package,
                deliveryNo: "@(Model?.DeliveryNo)"
            }
        });

        setTimeout(function () {
            initLayui();
        }, 50);
        function initLayui() {
            layui.use(['form', 'layer', 'index', 'table'], function () {
                var table = layui.table;

                var option = {
                    elem: '#table'
                    , url: '/Plan/QueryDispatchProducts'
                    , method: "post"
                    , where: { deliveryNo: vm.$data.deliveryNo }
                    , page: false
                    , limit: 10000
                    , response: {
                        statusName: 'ErrCode'
                        , statusCode: 200
                        , msgName: 'ErrCode'
                        , countName: 'TotalCount'
                        , dataName: 'Data'
                    }
                    , cols: [[
                        { title: '序号', type: "numbers", width: 60, fixed: "left" }
                        , { field: 'CabinetNo', title: '柜号', minWidth: 150 }
                        , { field: 'OrderNo', title: '订单号', minWidth: 150 }
                        , { field: 'WorkOrderNo', title: '工单号', minWidth: 200 }
                        , { field: 'PackQuantity', title: '包装数量', minWidth: 100 }
                        , { field: 'ProductCode', title: '物料编码', minWidth: 200 }
                        , { field: 'ProductName', title: '物料名称', minWidth: 200 }
                        , { field: 'ProductSpecs', title: '物料规格', minWidth: 200 }
                        , { field: 'ComponentColor', title: '物件颜色', minWidth: 100 }
                        , { field: 'NameplateModel', title: '铭牌型号', minWidth: 150 }
                        , { field: 'IVPowerLevel', title: '功率档', minWidth: 100 }
                    ]]
                };
                table.render(option);

                $("#btnEdit").click(function () {
                    layer.open({
                        type: 2,
                        shade: [0.1, '#000'],
                        area: ['550px', '380px'],
                        content: "/Plan/EditDeliveryCabinets?deliveryNo=" + vm.$data.deliveryNo,
                        end: function () {
                            table.reload("table", option);
                        }
                    });
                });
            });
        }
    </script>
}
